VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmReview 
   BackColor       =   &H80000018&
   Caption         =   "Review list"
   ClientHeight    =   4020
   ClientLeft      =   3180
   ClientTop       =   1770
   ClientWidth     =   5460
   LinkTopic       =   "Form1"
   ScaleHeight     =   4020
   ScaleWidth      =   5460
   Begin VB.TextBox txtLoai 
      Height          =   315
      Left            =   4095
      TabIndex        =   5
      Top             =   510
      Visible         =   0   'False
      Width           =   1050
   End
   Begin MSDataGridLib.DataGrid GridList 
      Bindings        =   "frmReview.frx":0000
      Height          =   2850
      Left            =   165
      TabIndex        =   4
      Top             =   975
      Width           =   5190
      _ExtentX        =   9155
      _ExtentY        =   5027
      _Version        =   393216
      BackColor       =   14737632
      ForeColor       =   8388608
      HeadLines       =   1
      RowHeight       =   15
      FormatLocked    =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   6
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1036
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   "THDOC"
         Caption         =   "Doc No"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1036
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column02 
         DataField       =   "THTTC"
         Caption         =   "Trans Code"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1036
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column03 
         DataField       =   "TCDSC"
         Caption         =   "Trans Desc"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1036
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column04 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column05 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1036
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
            ColumnWidth     =   14.74
         EndProperty
         BeginProperty Column01 
         EndProperty
         BeginProperty Column02 
         EndProperty
         BeginProperty Column03 
         EndProperty
         BeginProperty Column04 
            Object.Visible         =   0   'False
         EndProperty
         BeginProperty Column05 
            ColumnWidth     =   14.74
         EndProperty
      EndProperty
   End
   Begin VB.TextBox txtYear 
      Height          =   300
      Left            =   3390
      TabIndex        =   1
      Top             =   375
      Width           =   750
   End
   Begin VB.TextBox txtMonth 
      Height          =   285
      Left            =   1800
      TabIndex        =   0
      Top             =   360
      Width           =   510
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   2400
      Top             =   -75
      Visible         =   0   'False
      Width           =   2715
      _ExtentX        =   4789
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   "QLDonDatHang"
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "1.DDH"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Year"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   240
      Left            =   2790
      TabIndex        =   3
      Top             =   390
      Width           =   510
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Month"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   240
      Left            =   1050
      TabIndex        =   2
      Top             =   405
      Width           =   720
   End
End
Attribute VB_Name = "frmReview"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim frmreviewTag As String
Sub MoFile(Loai)
'27/04/2004 Bo sung ord540 thay ehstt=b
Dim dem As Byte
dem = 1
On Error GoTo ktra
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 40
Adodc1.CommandType = adCmdText

Select Case Loai
    Case "INV500"
        Adodc1.RecordSource = "SELECT GroupITHDoc.*" & _
            " From GroupITHDoc" & _
            " WHERE (Month(THDTE)=" & Val(txtMonth) & ") And (Year(THDTE)= " & Val(txtYear) & ")" & _
            " ORDER BY THDTE DESC, THDOC DESC"
    Case "INV540"
        Adodc1.RecordSource = "SELECT TCTNO,TCDTE from ICT " & _
        " where (month(TCDTE)=" & Val(txtMonth) & ") And (Year(TCDTE)= " & Val(txtYear) & ")" & _
        " group by TCTNO,TCDTE"
    Case "BBL500"
        Adodc1.RecordSource = "Select * from BBH where (month(BHDTE)=" & Val(txtMonth) & ") And (Year(BHDTE)= " & Val(txtYear) & ")" & _
            " AND ((BBH.BHFOD IS NULL) OR (BBH.BHFOD <> 'Y')) " & _
            " ORDER BY BHDTE DES,CBHIVN DESC"
     Case "BBL400"
        Adodc1.RecordSource = "Select * from BBH where  BBH.BHSTT='1'  ORDER BY BHDTE DESC,BHIVN DESC"
    Case "BBL410"
        Adodc1.RecordSource = "Select * from BBH where  BBH.BHSTT='2'  ORDER BY BHDTE DESC,BHIVN DESC"
    Case "ORD500"
        Adodc1.RecordSource = "Select * from ECH where (month(EHDTE)=" & Val(txtMonth) & ") And (Year(EHDTE)= " & Val(txtYear) & ")" & _
            " ORDER BY EHDTE DESC,EHODN DESC"
    Case "ORD540"
       ' Adodc1.RecordSource = "Select * from ECH where (month(EHDTE)=" & Val(txtMonth) & ") And (Year(EHDTE)= " & Val(txtYear) & ")" & _
            " AND (EHSTT='1' OR EHSTT='2' OR EHSTT='3' OR EHSTT='4') ORDER BY EHODN DESC"
             Adodc1.RecordSource = "Select ech.ehodn from ECH where (month(EHDTE)=" & Val(txtMonth) & ") And (Year(EHDTE)= " & Val(txtYear) & ")" & _
            " AND ((EHSTT='B')OR (EHSTT='2'))  ORDER BY EHDTE DESC,EHODN DESC"
     Case "ORD560"
      
             Adodc1.RecordSource = "Select * from ECH where (month(EHDTE)=" & Val(txtMonth) & ") And (Year(EHDTE)= " & Val(txtYear) & ")" & _
            " AND (EHSTT='2') ORDER BY EHDTE DESC,EHODN DESC"
    Case "PUR500"
        Adodc1.RecordSource = "Select * from POH where (month(OHPOD)=" & Val(txtMonth) & ") And (Year(OHPOD)= " & Val(txtYear) & ")" & _
            " ORDER BY OHPOD DESC,OHPON DESC"
        'MsgBox "Select * from POH where (month(OHPOD)=" & Val(txtMonth) & ") And (Year(OHPOD)= " & Val(txtYear) & ")" & _
            " ORDER BY OHPON DESC"
    Case "ACR500"
        Adodc1.RecordSource = "Select * from ACR where (month(ARDTE)=" & Val(txtMonth) & ") And (Year(ARDTE)= " & Val(txtYear) & ")" & _
            " ORDER BY ARDOC DESC"
    Case "RAR500"
        Adodc1.RecordSource = "Select ARDOC, ARCNO from RAR where (month(ARDTE)=" & Val(txtMonth) & ") And (Year(ARDTE)= " & Val(txtYear) & "AND ARTYP='P' " & ")" & _
            " GROUP BY ARDOC, ARCNO ORDER BY ARDOC DESC"
End Select

Adodc1.Refresh
' MsgBox Adodc1.Recordset.RecordCount
GridList.Refresh

Exit Sub
Reconnect:
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 40
Adodc1.CommandType = adCmdText

ktra:
If Err.Description = "[Microsoft][ODBC SQL Server Driver]Timeout expired" Then
   dem = dem + 1
   GoTo Reconnect
   If dem > 3 Then
       MsgBox "Dang nghe~n duong mang vao lai chuong trinh sau."
       End
   End If
End If
End Sub




Private Sub Form_Activate()
txtLoai = frmReview.Tag
ManHinh txtLoai
MoFile txtLoai
End Sub

Private Sub Form_Load()

txtMonth = Month(WorkingDate)
txtYear = Year(WorkingDate)

End Sub

Private Sub gridlist_DblClick()

If Adodc1.Recordset.RecordCount > 0 Then
    frmReview.Tag = GridList.Columns(1).value
Else
    frmReview.Tag = ""
End If
frmReview.Hide
End Sub



Private Sub txtyear_Change()
If txtLoai <> "" Then
    MoFile txtLoai
End If

End Sub

Private Sub txtmonth_Change()
If txtLoai <> "" Then
    MoFile txtLoai
End If
End Sub
Sub ManHinh(Loai)

Select Case Loai
    Case "INV500"
        GridList.Columns(1).DataField = "THDOC"
        GridList.Columns(1).Caption = "Doc No"
        GridList.Columns(2).DataField = "THDTE"
        GridList.Columns(2).Caption = "Trans Date"
        GridList.Columns(3).DataField = "TCDSC"
        GridList.Columns(3).Caption = "Trans Desc"
        GridList.Columns(4).DataField = "THTTC"
        GridList.Columns(4).Caption = "Trans Code"
    Case "INV540"
        GridList.Columns(1).DataField = "TCTNO"
        GridList.Columns(1).Caption = "Tag NO"
        GridList.Columns(2).DataField = "TCDTE"
        GridList.Columns(2).Caption = "Tag Date"
        GridList.Columns(3).Visible = False
    Case "BBL500"
        GridList.Columns(1).DataField = "BHIVN"
        GridList.Columns(1).Caption = "Invoice No"
        GridList.Columns(2).DataField = "BHDTE"
        GridList.Columns(2).Caption = "Invoice Date"
        GridList.Columns(3).Visible = False
    Case "BBL400"
        txtMonth.Visible = False
        txtYear.Visible = False
        GridList.Columns(1).DataField = "BHIVN"
        GridList.Columns(1).Caption = "Invoice No"
        GridList.Columns(2).DataField = "BHDTE"
        GridList.Columns(2).Caption = "Invoice Date"
        GridList.Columns(3).Visible = False
   Case "BBL410"
          txtMonth.Visible = False
        txtYear.Visible = False

        GridList.Columns(1).DataField = "BHIVN"
        GridList.Columns(1).Caption = "Invoice No"
        GridList.Columns(2).DataField = "BHDTE"
        GridList.Columns(2).Caption = "Invoice Date"
        GridList.Columns(3).Visible = False
    Case "ORD500"
        GridList.Columns(1).DataField = "EHODN"
        GridList.Columns(1).Caption = "Order No"
        GridList.Columns(2).DataField = "EHDTE"
        GridList.Columns(2).Caption = "Order Date"
        'GridList.Columns(2).DataFormat = 102
        GridList.Columns(3).Visible = False
     Case "ORD540"
        GridList.Columns(1).DataField = "EHODN"
        GridList.Columns(1).Caption = "Order No"
        GridList.Columns(2).DataField = "EHDTE"
        GridList.Columns(2).Caption = "Order Date"
        GridList.Columns(3).Visible = False
    Case "ORD560"
        GridList.Columns(1).DataField = "EHODN"
        GridList.Columns(1).Caption = "Order No"
        GridList.Columns(2).DataField = "EHDTE"
        GridList.Columns(2).Caption = "Order Date"
        GridList.Columns(3).Visible = False
    Case "PUR500"
        GridList.Columns(1).DataField = "OHPON"
        GridList.Columns(1).Caption = "PO No"
        GridList.Columns(2).DataField = "OHPOD"
        GridList.Columns(2).Caption = "PO Date"
        GridList.Columns(3).Visible = False
        'GridList.Columns(3).Caption = "Trans Desc"
    Case "ACR500"
        GridList.Columns(1).DataField = "ARDOC"
        GridList.Columns(1).Caption = "DOC No"
        GridList.Columns(2).DataField = "ARRFD"
        GridList.Columns(2).Caption = "Ref No"
        GridList.Columns(3).DataField = "ARDTE"
        GridList.Columns(3).Caption = "Date"
    Case "RAR500"
        GridList.Columns(1).DataField = "ARDOC"
        GridList.Columns(1).Caption = "DOC No"
        GridList.Columns(2).DataField = "ARDTE"
        GridList.Columns(2).Caption = "Date"
End Select
End Sub
